﻿<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %>
<table>
    <tr>
        <td width="890px">
            <input type="submit" class="button middle-button" value="Show History" onclick="showHistory('<%:ViewData("EntityType") %>',<%:ViewData("EntityID") %>,'historyContent');" />
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td id="historyContent">
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
</table>
<div id="detailDialog" title="History Detail" class="hidden">
<span>Loading...</span>
</div>
<script type="text/javascript">

    function showHistory(entityType, entityID, contentIDToUpdate) {
        showLoading("historyContent", true);
        jQuery.ajax({
            type: 'POST',
            data: { entityType: entityType, entityID: entityID, pageNo: 1 },
            url: '<%= Url.Content("~/History/EntityHistory") %>',
            success: function (result) {
                $('#' + contentIDToUpdate).html(result);
                $("#historyTable").tablesorter({ widthFixed: true, widgets: ['zebra'] })
                .tablesorterPager({ container: $("#pager"), positionFixed: false });
                hideLoading("historyContent");
            }
        });
    }


    var detailDialog = {
        show: function (id) { showDetail(id); },
        close: function () { closeDialog(); },
        OnSuccess: null
    }


    function closeDialog() {
        $("#detailDialog").dialog("close");
    }

    function showDetail(id) {
        $('#detailDialog').html("<span>Loading...</span>");
        $("#detailDialog").dialog({
            modal: true,
            width: 600,
            height: 400,
            zIndex: 100
        });

        jQuery.ajax({
            type: 'POST',
            data: { id: id },
            url: '<%= Url.Content("~/History/Detail") %>',
            success: function (result) {
                $('#detailDialog').html(result);
            }
        });

    }

</script>
